#include <bits/stdc++.h>
using namespace std;
class Solution
{
public:
  int maximumCostSubstring(string s, string chars, vector<int> &vals)
  {
    int cost[26]{};
    for (int i = 0; i < 26; i++)
      cost[i] = i + 1;
    for (int i = 0; i < chars.length(); i++)
    {
      cost[chars[i] - 'a'] = vals[i];
    }
    int dp[100010]{};
    int ans = 0;
    // 以chars[i]结尾字串的最大开销
    for (int i = 1; i <= s.length(); i++)
    {
      // cout<<chars[i - 1]<<' '<<i<<'\n';
      dp[i] = max(cost[s[i - 1] - 'a'], dp[i - 1] + cost[s[i - 1] - 'a']);
      ans = max(ans, dp[i]);
    }
    return ans;
  }
};
int main()
{
  Solution s;

  return 0;
}
